*************************************************************
* Replication file:											*
* From the streets to the voting booth 						*
* Main manuscript											*
* Authors: Colombo, Ferrara, Dinas, Vassou, Bernardi   		*
*															*
*************************************************************



* INSERT WORKING DIRECTORY:
global wd ""

* Set style for plots
set scheme plotplain
graph set window fontface "Times New Roman"

************************************************
* FIGURE 2.a
************************************************

* original treatment
use "$wd/main_data.dta", clear
xtset town election_year

xtreg rrp_vs i.b2014.election_year##i.treated_orig if regione=="EMILIAROMAGNA", cluster(town)
margins, at(election_year=(1995 2000 2005 2010 2014 2020) treated = (0 1))
marginsplot, ///
	plot1opts(msymbol(D) mcolor("gs12") fcolor("gs12") lcolor("gs12") msize(medsmall) lwidth(med)) ///
	ci1opts(lcolor("gs12") lwidth(medthick)) ///
	plot2opts(msymbol(O) mcolor("gs1") fcolor("gs1") lcolor("gs1") msize(medsmall) lwidth(med))  ///
	ci2opts(lcolor("gs1") lwidth(medthick)) ///
	aspect(1) ///	
	ytitle("FRP vote share", height(5) size(large)) ///
	xtitle("Election", height(5) size(large)) ///
	yscale(range(0 30)) ///
	ylabel(0(10)50, grid glcolor(gray%80) labs(medl) glw(medium) ) ///
	xlabel(, grid glcolor(gray%80) labs(medl) glw(medium) ) ///	
	title("", size(large)) ///
	legend( ///
		region(lwidth(none)) ///
		size(medl) ///
		col(2) ///
		position(6) ///
		order(3 "Control" 4 "Treated"))	
graph export "$wd/figure2a.pdf", replace

************************************************
* FIGURE 2.b
************************************************

* Adjacent treatment
use "$wd/main_data.dta", clear
drop if treated_orig==1
xtset town election_year

xtreg rrp_vs i.b2014.election_year##i.treated_adj if regione=="EMILIAROMAGNA", cluster(town)
margins, at(election_year=(1995 2000 2005 2010 2014 2020) treated = (0 1))
marginsplot, ///
	plot1opts(msymbol(D) mcolor("gs12") fcolor("gs12") lcolor("gs12") msize(medsmall) lwidth(med)) ///
	ci1opts(lcolor("gs12") lwidth(medthick)) ///
	plot2opts(msymbol(O) mcolor("gs1") fcolor("gs1")  lcolor("gs1") msize(medsmall) lwidth(med))  ///
	ci2opts(lcolor("gs1") lwidth(medthick)) ///
	aspect(1) ///	
	ytitle("FRP vote share", height(5) size(large)) ///
	xtitle("Election", height(5) size(large)) ///
	yscale(range(0 30)) ///
	ylabel(0(10)50, grid glcolor(gray%80) labs(medl) glw(medium) ) ///
	xlabel(, grid glcolor(gray%80) labs(medl) glw(medium) ) ///	
	title("") ///
	legend( ///
		region(lwidth(none)) ///
		col(2) ///
		size(medl) ///
		position(6) ///
		order(3 "Control" 4 "Treated"))	
graph export "$wd/figure2b.pdf", replace

************************************************
* FIGURE 3.a + 3.b
************************************************

use "$wd/main_data.dta", clear
xtset town election_year

foreach level in 95 90 {

* Original treatment
xtreg rrp_vs i.b2014.election_year treatment_orig if regione=="EMILIAROMAGNA" , cluster(town) fe
lincomest treatment_orig, level(`level')

parmest, label saving("$wd/temporary estimates/main_`level'_emilia.dta", replace) level(`level')

* Original treatment - municipality trends
xtreg rrp_vs i.b2014.election_year treatment_orig town##c.election_year#c.election_year if regione=="EMILIAROMAGNA" , cluster(town) fe
lincomest treatment_orig, level(`level')

parmest, label saving("$wd/temporary estimates/main_trend_`level'_emilia.dta", replace) level(`level')

* Original treatment - Placebo
xtreg rrp_vs_lag i.b2014.election_year treatment_orig if regione=="EMILIAROMAGNA" , cluster(town) fe
lincomest treatment_orig, level(`level')

parmest, label saving("$wd/temporary estimates/placebo_main_`level'_emilia.dta", replace) level(`level')

* Original treatment - Placebo + trends
xtreg rrp_vs_lag i.b2014.election_year treatment_orig town##c.election_year#c.election_year if regione=="EMILIAROMAGNA" , cluster(town) fe
lincomest treatment_orig, level(`level')

parmest, label saving("$wd/temporary estimates/placebo_main_trend_`level'_emilia.dta", replace) level(`level')

* Adjacent treatment
preserve
	drop if treated_orig==1
	xtreg rrp_vs i.b2014.election_year treatment_adj if regione=="EMILIAROMAGNA" , cluster(town) fe
	lincomest treatment_adj, level(`level')
	
	parmest, label saving("$wd/temporary estimates/adjacent_`level'_emilia.dta", replace) level(`level')
restore

* Adjacent treatment - municipality trends

preserve
	drop if treated_orig==1
	xtreg rrp_vs i.b2014.election_year treatment_adj town##c.election_year#c.election_year if regione=="EMILIAROMAGNA" , cluster(town) fe
	lincomest treatment_adj, level(`level')
	
	parmest, label saving("$wd/temporary estimates/adjacent_trend_`level'_emilia.dta", replace) level(`level')
restore

* Adjacent treatment - Placebo
preserve
	drop if treated_orig==1
	xtreg rrp_vs_lag i.b2014.election_year treatment_adj if regione=="EMILIAROMAGNA" , cluster(town) fe
	lincomest treatment_adj, level(`level')
	parmest, label saving("$wd/temporary estimates/placebo_adjacent_`level'_emilia.dta", replace) level(`level')
restore

* Adjacent treatment - Placebo + trends
preserve
	drop if treated_orig==1
	xtreg rrp_vs_lag i.b2014.election_year treatment_adj town##c.election_year#c.election_year if regione=="EMILIAROMAGNA" , cluster(town) fe
	lincomest treatment_adj, level(`level')
	
	parmest, label saving("$wd/temporary estimates/placebo_adjacent_trend_`level'_emilia.dta", replace) level(`level')
restore

}


foreach model in main_ main_trend_ placebo_main_ placebo_main_trend_ adjacent_ adjacent_trend_  placebo_adjacent_  placebo_adjacent_trend_ {
	foreach level in 95 90 {

	use "$wd/temporary estimates/`model'`level'_emilia.dta", clear
	gen model = "`model'"

	save "$wd/temporary estimates/`model'`level'_emilia.dta", replace

	}
}

foreach level in 95 90 {

	clear
	foreach model in main_ main_trend_ placebo_main_ placebo_main_trend_ adjacent_ adjacent_trend_  placebo_adjacent_  placebo_adjacent_trend_   {
	append using "$wd/temporary estimates/`model'`level'_emilia.dta"
	}
save "$wd/temporary estimates/`level'_intervals_emilia.dta", replace

}

************************************************
* FIGURE 3.a
************************************************

frames reset
use "$wd/temporary estimates/95_intervals_emilia.dta", clear
merge 1:1 model using "$wd/temporary estimates/90_intervals_emilia", nogen
keep model estimate min95 min90 max95 max90 p label
format p %3.2f
order model label

* Main effects plot

frame copy default main
frame change main
keep if model=="main_"

gen y=1

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D) ) ///
	, ///
	xtitle("", size(large)) ///
	ytitle("") ///
	legend(off) ///
	xline(0, lcolor(gs12)) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	ylabel(1 "ATT", grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 1.5)) ///
	fysize(40) ///
	graphregion(margin(25 0 0 0)) ///
	subtitle("A. Main treatment", box fcolor(gs14) bexpand size(huge)) ///
	name(main, replace)
	
* Robustness checks

frame copy default main_trend
frame change main_trend
keep if model=="main_trend_"

gen y=1

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D)) ///
	, ///
	xtitle("", size(large)) ///
	ytitle("") ///
	legend(off) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	xline(0, lcolor(gs12)) ///
	ylabel(1 "ATT", grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 1.5)) ///
	graphregion(margin(25 0 0 0)) ///
	fysize(40) ///
	subtitle("B. Robustness check (controlling for time trend)", box fcolor(gs14) bexpand size(huge)) ///
	name(rob_main, replace)

* Placebo tests

frame copy default placebo
frame change placebo
keep if model=="placebo_main_" | model=="placebo_main_trend_"

gen y=1

replace y=2 if model=="placebo_main_trend_"

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D) ) ///
	, ///
	xtitle("FRP vote share", size(large)) ///
	ytitle("") ///
	legend(off) ///
	xline(0, lcolor(gs12)) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	ylabel(1  "ATT" 2 "ATT - time trend",  grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 2.5) lstyle(none)) ///
	graphregion(margin(0 0 0 0)) ///
	fysize(60) ///
	subtitle("C. Placebo treatment (lagged outcome)", box fcolor(gs14) bexpand size(huge)) ///
	name(placebo_main, replace)
	
	
graph combine  main rob_main placebo_main, ///
	col(1) ///
	name(plot_combine, replace)
graph display plot_combine, ysize(4)	
graph export "$wd/Figure3a.pdf", replace

************************************************
* FIGURE 3.b - RESULTS COEFPLOT
************************************************

* adjacent treatment

frame copy default adj
frame change adj
keep if model=="adjacent_"

gen y=1

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D) ) ///
	, ///
	xtitle("", size(large)) ///
	ytitle("") ///
	legend(off) ///
	xline(0, lcolor(gs12)) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	ylabel(1 "ATT", grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 1.5)) ///
	fysize(40) ///
	graphregion(margin(25 0 0 0)) ///
	subtitle("D. Adjacent treatment", box fcolor(gs14) bexpand size(huge)) ///
	name(adj, replace)
	
* Robustness checks

frame copy default adj_trend
frame change adj_trend
keep if model=="adjacent_trend_"

gen y=1

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D) ) ///
	, ///
	xtitle("", size(vlarge)) ///
	ytitle("") ///
	legend(off) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	xline(0, lcolor(gs12)) ///
	ylabel(1 "ATT", grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 1.5)) ///
	graphregion(margin(25 0 0 0)) ///
	fysize(40) ///
	subtitle("E. Robustness check (controlling for time trend)", box fcolor(gs14) bexpand size(huge)) ///
	name(rob_adj, replace)

* Placebo tests

frame copy default placebo_adj
frame change placebo_adj
keep if model=="placebo_adjacent_" | model=="placebo_adjacent_trend_"

gen y=1

replace y=2 if model=="placebo_adjacent_trend_"

tw rcap min90 max90 y, ///
	horizontal ///
	ysc(reverse) ///
	lw(medthick) ///
	lc(gs1) ///
|| rcap min95 max95 y, ///
	horizontal ysc(reverse) ///
	lw(thin) ///
	lc(gs1) ///
|| 	(scatter y estimate,  ///
	ysc(reverse) ///
	lc(gs1) ///
	mc(gs1) ///
	msymbol(D) ) ///
	, ///
	xtitle("FRP vote share", size(large)) ///
	ytitle("") ///
	legend(off) ///
	xline(0, lcolor(gs12)) ///
	xlabel(-10(2)10,  grid glcolor(gray%80) labs(large) glw(medium) ) ///
	xscale(range(-11 11)) ///
	ylabel(1  "ATT" 2 "ATT - time trend",  grid glcolor(gray%80) labs(large) glw(medium) angle(horizontal)) ///
	yscale(range(0.5 2.5) lstyle(none)) ///
	graphregion(margin(0 0 0 0)) ///
	fysize(60) ///
	subtitle("F. Placebo treatment (lagged outcome)", box fcolor(gs14) bexpand size(huge)) ///
	name(placebo_adj, replace)

graph combine  adj rob_adj placebo_adj, ///
	col(1) ///
	name(plot_combine, replace)
graph display plot_combine, ysize(4)
graph export "$wd/Figure3b.pdf", replace

